<!DOCTYPE html>
<html>
<?php $this->load->view('admin/public/header.html');?>
<style>
    . space{padding:10px;}

</style>
<body class="childrenBody">
<form class="layui-form layui-row layui-col-space20" lay-filter="expert_form">
    <!--<div class="layui-col-md6">
        <div class="layui-form-item magb0">
            <label class="layui-form-label">回复内容</label>
            <div class="layui-input-block">
                <textarea class="layui-textarea layui-hide" name="content" lay-verify="content" id="content"></textarea>
                <input type="hidden" class="layui-input name" name="tocommentId" lay-verify="require">
                <input type="hidden" class="layui-input name" name="userId" value="<?php echo $this->session->userdata('sellerId')?>" lay-verify="require" disabled >
            </div>
        </div>
    </div>

    <div class="">
        <div class="layui-right">
            <a class="layui-btn layui-btn-sm" lay-filter="addNews" lay-submit><i class="layui-icon">&#xe609;</i>发布</a>
        </div>
    </div>-->
    <!--<div class="layui-col-md6 layui-col-xs12 ">-->
        <div class="layui-row layui-col-space10">
            <!--<div class="layui-col-md12 layui-col-xs7">-->
                <div class="layui-form-item">
                    <label class="layui-form-label">回复内容</label>
                    <div class="layui-input-block">
                        <textarea placeholder="请输入回复内容" name="content"  lay-verify="required" class="layui-textarea brief"></textarea>
                        <input type="hidden" class="layui-input name" name="tocommentId" lay-verify="require">
                        <input type="hidden" class="layui-input name" name="userId" value="<?php echo $this->session->userdata('sellerId')?>" lay-verify="require" disabled >
                        <input type="hidden" class="layui-input name" name="type" lay-verify="require" disabled >
                    </div>
                </div>
                <div class="layui-form-item magt3">
                    <div class="layui-row layui-col-space10">
                        <div class="layui-col-md12 layui-col-xs6">
                            <label class="layui-form-label">上传图片</label>
                            <div class="layui-upload-list thumbBox posterBox" style="display: flex; width: 150px; height: 150px;float: left; margin-right: 15px">
                                <img class="layui-upload-img thumbImg posterimg" src="" style="width: 150px; height: 150px;">
                                <input type="hidden" class="poster" lay-verify="required" value="" name="imagePath[]">
                            </div>

                            <!--<div class="layui-upload-list thumbBox posterBox" style="display: flex; width: 150px; height: 150px;float: left; margin-right: 15px">
                                <img class="layui-upload-img thumbImg posterimg" src="111111111" name="imgeas[]" style="display: flex; width: 150px; height: 150px;">
                            </div>

                            <div class="layui-upload-list thumbBox posterBox" style="display: flex; width: 150px; height: 150px;">
                                <img class="layui-upload-img thumbImg posterimg" src="111111111" name="imgeas[]" style="display: flex; width: 150px; height: 150px;">
                            </div>-->
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-right">
                <a class="layui-btn " lay-submit  lay-filter="commentSubmit">保存</a>
            </div>

        <!--</div>-->
    <!--</div>-->
</form>
<script type="text/javascript">
    var path='/public/appeditor/';
    layui.config({
        base : path
    }).extend({
        "appeditor" : "appeditor"
    })
    layui.use(['form','layer','layedit','laydate','upload',],function(){


        var form = layui.form
        layer = parent.layer === undefined ? layui.layer : top.layer,
            laypage = layui.laypage,
            upload = layui.upload,
            layedit = layui.layedit,
            laydate = layui.laydate,
            $ = layui.jquery;



        // var layerindex;		//弹层句柄
        // //上传缩略图
        // upload.render({
        //     elem: '.posterBox',
        //     //multiple:true,
        //     url: '<?php echo site_url("upload/upload")?>',
        //     before: function(obj){ //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
        //         layerindex=layer.load(); //上传loading
        //     },
        //     done: function(res, index, upload){
        //         console.log(1);
        //         layer.close(layerindex);
        //         if(res.code==200){
        //             layer.msg('上传成功');
        //             var url=res.content.url
        //             var src='<?php echo IMAGEHOST?>'+url;
        //             $('.posterimg').attr('src',src);
        //             $('.thumbBox').css("background","#fff");
        //             $(".poster").val(url);
        //             $(".layui-form-label").append("<div class=\"layui-upload-list thumbBox posterBox\" style=\"display: flex; width: 150px; height: 150px;float: left; margin-right: 15px\">\n" +
        //                 "                                <img class=\"layui-upload-img thumbImg posterimg\" src=\"\" style=\"width: 150px; height: 150px;\">\n" +
        //                 "                                <input type=\"hidden\" class=\"poster\" lay-verify=\"required\" value=\"\" name=\"imagePath[]\">\n" +
        //                 "                            </div>");
        //         }else{
        //             layer.msg('上传失败');
        //         }
        //     }
        // });

        //格式化时间
        function filterTime(val){
            if(val < 10){
                return "0" + val;
            }else{
                return val;
            }
        }
        form.on("submit(commentSubmit)",function(data){
            // console.log(data)
            var index=layer.load();
            $.ajax({
                type:'post',
                data:data.field,
                url:'<?php echo site_url("seller/comment/addrepaly")?>',
                dataType: "json",
                success:function(res){
                    //console.log(res.code);return;
                    if(res.code==200){
                        top.layer.close(index);
                        top.layer.msg("操作成功！");
                        //刷新父页面
                        if(data.type == 'project') {
                            location.href="<?php echo site_url('seller/comment/project')?>";
                        }else if(data.type == 'technician') {
                            location.href="<?php echo site_url('seller/comment/technician')?>";
                        }else {
                            location.href="<?php echo site_url('seller/comment/company')?>";
                        }
                        //parent.location.reload();
                        // location.href=history.back();
                    }else{
                        top.layer.close(index);
                        top.layer.msg("操作失败！");
                    }
                },
                fail:function(){
                    top.layer.close(index);
                    top.layer.msg("操作失败！");
                }
            })
            return false;
        })

        //创建一个编辑器
        var editIndex = layedit.build('content',{
            height : 535,
            uploadImage : {
                url : "<?php echo site_url('upload/editUpload')?>"
            }
        });
        //用于同步编辑器内容到textarea
        layedit.sync(editIndex);

    })
</script>
</body>
</html>